# jar 包文件名
project_jar_name=jenkins-0.0.1-SNAPSHOT.jar

# 项目 jar 文件路径
project_target=${JENKINS_HOME}/workspace/MySpingBootProject/jenkinsDemo/target/

# 项目的Dockerfile 文件路径
project_dockerfile=${JENKINS_HOME}/workspace/MySpingBootProject/jenkinsDemo/Dockerfile

# 拷贝项目和Docker文件jar包位置
cp ${project_dockerfile} ${project_target}

# 编译成images
cd ${project_target}

docker build -t jenkins-test .

echo "查找运行的容器...."
need_rm=`docker ps -a | grep jenkins-test`

if [ "${need_rm}"x != ""x ]; then
    echo "强制删除容器"
    docker rm -f jenkins-test
fi

echo "运行容器..."
